package com.dbw.inputmethod;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class QQWubiLibParser implements CharCodeLibParser {

    public QQWubiLibParser() {
        
    }

    @Override
    public List<CharCode> parse(File libFile) {
        
        Scanner scanner = null;
        List<CharCode> charCodeList = new ArrayList<>();
        try {
            scanner = new Scanner(libFile);
            while(scanner.hasNextLine()) {
                String line = scanner.nextLine();
                String[] items = line.split("\\s+");
                if(items == null || items.length < 2) {
                    continue;
                }
                for(int i = 1; i < items.length; i++) {
                    charCodeList.add(new CharCode(items[i], items[0]));
                }
            }
            scanner.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        
        return charCodeList;
    }

}
